package com.wlr.study.juc;

import java.util.concurrent.*;

/**
 * @author lrwang
 * @version 1.0
 * @date 2023/2/6 9:33
 * @since 1.8
 */
public class CompletableFutureTest {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        ExecutorService executorService = Executors.newFixedThreadPool(3);
        CompletableFuture<Void> test = CompletableFuture.runAsync(() -> {
            System.out.println(Thread.currentThread().getName());
            try {
                TimeUnit.SECONDS.sleep(1);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }, executorService);
        System.out.println(test.get());
        executorService.shutdown();
    }
}
